<?php

/**
* @Author:  	Daniel Dinh
* @Email:   	webdevelopmentvn@gmail.com
* @Link: 		http://www.joomsoft.net
* @Version: 	1.0
* @copyright:	Joomsoft.net
* @license:		Commercial
*/

// no direct access
defined('_JEXEC') or die;


?>
<form action="<?php echo JRoute::_('index.php?option=com_jsnplugin&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="client-form">


<?php if($this->item->id):?>
	<H3><a href="index.php?option=com_jsnplugin&view=jsnfields&pid=<?php echo $this->item->id;?>" target="_blank">Field Manager</a>
<?php endif;?></H3>

<table class="adminform">
	<tbody>
		<?php foreach($this->form->getFieldset() as $field): ?>
			<tr>
				<td width="15%"><?php echo $field->label;?></td>
				<td><?php echo $field->input;?></td>
			</tr>
		<?php endforeach; ?>
	</tbody>	
	</table>
	
	<!-- language -->
	<?php if($this->item->language):?>
	<p>
	<br/>
	Reload Languages ?<input type="checkbox" name="reload_language" /></p>
	
	<?php echo JHtml::_('tabs.start', 'languages_tabs',array('useCookie'=>true));?>
	<?php foreach($this->item->language as $lang):?>
		<?php echo JHtml::_('tabs.panel', $lang,'tab_'.$lang);?>
		<textarea cols="150" rows="20" name="languages[]"><?php echo $_SESSION['reload_language'] || !$this->languages[$lang]->data ? $this->field_languages[$lang] : $this->languages[$lang]->data;?></textarea>
		<input type="hidden" name="data_language_id[]" value="<?php echo $this->languages[$lang]->id;?>" />
		<input type="hidden" name="data_language_name[]" value="<?php echo $lang;?>" />
		<br clear="all" />
	<?php endforeach;?>
	<?php echo JHtml::_('tabs.end');?> 
	<?php endif;?>
	
	<!-- plugin events -->
	<?php if($this->events):?>
	<p>
	Reload Events ?<input type="checkbox" name="reload_event" /></p>
	<?php echo JHtml::_('tabs.start', 'events_tabs',array('useCookie'=>true));?>
	<?php foreach($this->events as $event):?>
		<?php echo JHtml::_('tabs.panel', $event->title,'event_'.$event->title);?>
		<textarea cols="150" rows="20" name="events[]"><?php echo $_SESSION['reload_event'] || !$event->data ? $event->codes : $event->data;?></textarea>
		<input type="hidden" name="data_event_id[]" value="<?php echo $event->ed_id;?>" />
		<input type="hidden" name="events_id[]" value="<?php echo $event->id;?>" />
		<br clear="all" />
	<?php endforeach;?>
	<?php echo JHtml::_('tabs.end');?> 
	<?php endif;?>
	
	<input type="hidden" name="task" value="plugin.edit" />
	<?php echo JHtml::_('form.token'); ?>
</form>
<?php 

	unset($_SESSION['reload_language']);
	unset($_SESSION['reload_event']);

?>